package com.aidex.web.controller.api;

import com.aidex.biz.domain.Customer;
import com.aidex.biz.domain.RxkOrder;
import com.aidex.biz.service.CheYouRongOrderService;
import com.aidex.biz.service.CustomerService;
import com.aidex.biz.service.RxkOrderService;
import com.aidex.biz.smy.dto.BaseDTO;
import com.aidex.biz.smy.service.HitService;
import com.aidex.biz.smy.vo.BaseVO;
import com.aidex.biz.utils.AESUtils;
import com.aidex.biz.utils.RAESUtils;
import com.aidex.biz.utils.Rong360Codec;
import com.aidex.biz.utils.RongXiangKeAESUtil;
import com.aidex.common.annotation.Log;
import com.aidex.common.core.controller.BaseController;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.utils.StringUtils;
import com.aidex.common.utils.http.HttpUtils;
import com.aidex.common.utils.sign.Md5Utils;
import com.aidex.web.controller.tool.AesCytUtils;
import com.aidex.web.controller.tool.AesMxmUtils;
import com.aidex.web.controller.tool.Base64Util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.api.client.json.Json;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * 客户信息推送
 *
 * @author sean
 * @email 2074844820@qq.com
 * @date 2022-04-22
 */
@RestController("ApiPushCustomerController")
@RequestMapping("/webApi/pushCustomer")
public class PushCustomerController extends BaseController {
    @Autowired
    private CustomerService customerService;

    @Autowired
    private  HitService hitService;

    @Autowired
    private RxkOrderService  rxkOrderService;

    @Autowired
    private CheYouRongOrderService cheYouRongOrderService;

    /**
     * 已接通 1
     * @param customer
     * @return
     */
    @Log(title = "左心房客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertZxf", method = RequestMethod.POST)
    @ResponseBody
    public Map insertZxf(@RequestBody Customer customer) {
        customer.setLaiyuan("左心房");
        String[] area = customer.getCityName().split("-");
        if(area.length==2){
            customer.setCityName(area[1]);
        }
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通 2 周三对接
     * @param customer
     * @return
     */
    @Log(title = "欧乐客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertOuLe", method = RequestMethod.POST)
    @ResponseBody
    public Map insertOuLe(@RequestBody Customer customer) {
        customer.setLaiyuan("欧乐");
        String name=customer.getCusName();
        customer.setCusName(name.replaceAll("左心房","").replaceAll("（","").replaceAll(
                "）",""));
        return customerService.savePushCustomer(customer);
    }
    /**
     * 接通
     * @param customer
     * @return
     */
    @Log(title = "惠利客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertHuiLi", method = RequestMethod.POST)
    @ResponseBody
    public Map insertHuiLi(@RequestBody Customer customer) {
        customer.setLaiyuan("惠利");
        return customerService.savePushCustomer(customer);
    }

    /**
     * 大鹅客户推送信息(撞库)
     * @param param
     * @return
     */
    @Log(title = "大鹅客户推送信息(撞库)", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/check", method = RequestMethod.POST)
    @ResponseBody
    public BaseVO hitUser(@RequestBody BaseDTO param) {
        BaseVO baseVO = hitService.handlerHit(param);
        return baseVO;
    }

    /**
     * 已接通 4
     * @param param
     * @return
     */
    @Log(title = "大鹅客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/infoSubmit", method = RequestMethod.POST)
    @ResponseBody
    public BaseVO infoSubmit(@RequestBody BaseDTO param) {
        BaseVO baseVO = hitService.handlerCommit(param);
        return baseVO;
    }




    /**
     * 已接通 5
     * @param customer
     * @return
     */
    @Log(title = "巨匠客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertJujiang", method = RequestMethod.POST)
    @ResponseBody
    public Map insertJujiang(@RequestBody Customer customer) {
        customer.setLaiyuan("巨匠");
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通 6
     * @param jsonObject
     * @return
     */
    @Log(title = "客哆客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertKeDuo", method = RequestMethod.POST)
    @ResponseBody
    public Map insertKeDuo(@RequestBody JSONObject jsonObject) {
        Customer customer=new Customer();
        customer.setLaiyuan("客哆");
        customer.setCusName(jsonObject.getString("customer_name"));
        customer.setPhone(jsonObject.getString("customer_phone"));
        customer.setSex(jsonObject.getString("customer_sex"));
        customer.setCityName(jsonObject.getString("customer_region"));
        customer.setAmount(jsonObject.getString("loan_money"));
        customer.setRemark(jsonObject.getString("media")+"/"+jsonObject.getString("loan_type"));
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通
     * @param jsonObject
     * @return
     */
    @Log(title = "聚网客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertJuWang", method = RequestMethod.POST)
    @ResponseBody
    public Map insertJuWang(@RequestBody JSONObject jsonObject) {
        Customer customer=new Customer();
        customer.setLaiyuan("聚网");
        customer.setCusName(jsonObject.getString("cname"));
        customer.setPhone(jsonObject.getString("tel"));
        String sex="未知";
        if(null!=jsonObject.getInteger("sex")){
            if(jsonObject.getInteger("sex")==1){
                sex="女";
            }
            if(jsonObject.getInteger("sex")==2){
                sex="男";
            }
        }
        customer.setSex(sex);
        customer.setCityName(jsonObject.getString("city"));
        customer.setAmount(jsonObject.getString("xqed"));
        String laiyuan=jsonObject.getString("fromId");
        if("124".equals(laiyuan)){
            laiyuan="百度广告1";
        }
        if("94".equals(laiyuan)){
            laiyuan="百度广告2";
        }
        if("155".equals(laiyuan)){
            laiyuan="抖音广告";
        }
        if("191".equals(laiyuan)){
            laiyuan="腾讯广告";
        }

        customer.setRemark(laiyuan+"/"+jsonObject.getString("remarks"));
        if(null!=jsonObject.getInteger("n1")){
            customer.setAge(jsonObject.getInteger("n1"));
        }
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通 8
     * @param customer
     * @return
     */
    @Log(title = "通联沃数客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertLianTongWoShu", method = RequestMethod.POST)
    @ResponseBody
    public Map insertLianTongWoShu(@RequestBody Customer customer) {
        customer.setLaiyuan("通联沃数");
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通 9
     * @param customer
     * @return
     */
    @Log(title = "优搜客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertYouSou", method = RequestMethod.POST)
    @ResponseBody
    public Map insertYouSou(@RequestBody Customer customer) {
        customer.setLaiyuan("优搜");
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通 10 通用
     * @param customer
     * @return
     */
    @Log(title = "客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomer", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomer(@RequestBody Customer customer) {
        String city=customer.getCityName();
        String citys[]=city.split("-");
        if (citys.length==2){
            customer.setCityName(citys[1].replace("市",""));
        }else{
            customer.setCityName(city.replace("市",""));
        }
        return customerService.savePushCustomer(customer);
    }


    /**
     * 已接通 10 通用
     * @param customer
     * @return
     */
    @Log(title = "客户推送信息-117", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertJuLiang", method = RequestMethod.POST)
    @ResponseBody
    public Map insertJuLiang(@RequestBody Customer customer) {
        String city=customer.getCityName();
        String citys[]=city.split("-");
        if (citys.length==2){
            customer.setCityName(citys[1].replace("市",""));
        }else{
            customer.setCityName(city.replace("市",""));
        }
        customer.setLaiyuan("巨量H");
        return customerService.savePushCustomer(customer);
    }


    /**
     * 客户信息撞库查询 11 通用
     * @param customer
     * @return
     */
    @Log(title = "客户信息撞库查询", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/customerCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map customerCheck(@RequestBody Customer customer) {
        Map<String,Object> map=new HashMap<>();
        map.put("code","200");
        if (customerService.findCustomerByphone(customer)){
            map.put("data",false);
            map.put("msg","客户信息存在");
        }else{
            map.put("data",true);
            map.put("msg","客户信息不存在");
        }
        return map;
    }

    /**
     * 已接通 10
     * @param param
     * @return
     */
    @Log(title = "客户推送信息-车银", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByCheDiRong", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByCheDiRong(@RequestBody JSONObject param) throws Exception {

        Map map=new HashMap();
        if(StringUtils.isNotEmpty(param.getString("data"))){
            String dataRes= AESUtils.Decrypt(param.getString("data"),"kzhtybx8qzmjrc06");
            JSONObject jsonObject=JSONObject.parseObject(dataRes);
            if(null!=jsonObject){
                Customer customer=new Customer();
                customer.setAmount(jsonObject.getString("amount"));
                customer.setCityName(jsonObject.getString("cityName"));
                customer.setCarStatus(jsonObject.getString("carStatus"));
                customer.setCusName(jsonObject.getString("cusName"));
                customer.setPhone(jsonObject.getString("phone"));
                customer.setLaiyuan("车银");
                customer.setCusCanal(jsonObject.getString("dc"));
//                customer.setRemark(customer.getCusBody()+"/"+customer.getCusCanal()+"/"+customer.getRemark());
                return customerService.savePushCustomer(customer);
            }else {
                map.put("code","500");
                map.put("message","json is error");
            }
        }else{

            map.put("code","500");
            map.put("message","data is null");

        }
        return map;
    }




    /**
     * 融享客线索API
     * @param param
     * @return
     *
     * http://crm.cheyourong.com/api/webApi/pushCustomer/insertRongXiangKeOrderCustomer
     * http://47.97.80.183:8077/webApi/pushCustomer/insertRongXiangKeOrderCustomer
     */
    @Log(title = "融享客线索API", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertRongXiangKeOrderCustomer", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertRongXiangKeOrderCustomer(@RequestBody JSONObject param) throws Exception {
        JSONObject returnJson= new JSONObject();
        if(StringUtils.isEmpty(param.getString("orderNo"))){
            returnJson.put("code",4000);
            returnJson.put("message","orderNo is null");
            return returnJson;
        }
        RxkOrder rxkOrder=rxkOrderService.get(param.getString("orderNo"));
        if(null!=rxkOrder){
            returnJson.put("code",5000);
            returnJson.put("message","orderNo is verb");
            return returnJson;
        }else{
            rxkOrder=new RxkOrder();
            rxkOrder.setId(param.getString("orderNo"));
            rxkOrder.setIsNewRecord();
            rxkOrder.setOrderNo(param.getString("orderNo"));
            rxkOrder.setStatus("0");
        }



        String get_url="https://gw.youxinsign.com/rxk-saas/api/organ-clue-api/readClues";
        String voucherCode="3AIIJYJMI3UHVS5D";
        String key="5BPZ3OLV41U8HB5L";
        String orderNo=param.getString("orderNo");
        JSONObject params=new JSONObject();
        params.put("voucherCode",voucherCode);
        params.put("orderNo",orderNo);
        JSONObject jsonObject=JSONObject.parseObject(HttpUtils.doPost(get_url,params));
        if("1".equals(jsonObject.getString("code"))){
            JSONArray customerJsonList=JSONObject.parseArray(RAESUtils.decrypt(jsonObject.getString("data"),
                    key));
            for(int i=0;i<customerJsonList.size();i++) {
                JSONObject customerJson = customerJsonList.getJSONObject(i);
                if (null != customerJson) {
                    rxkOrder.setStatus("1"); // 读取成功
                    Customer customer = new Customer();
                    customer.setLaiyuan("融享客");
                    customer.setClueId(customerJson.getString("orderNo"));
                    customer.setCusCanal(customerJson.getString("source"));
                    customer.setCusBody(customerJson.getString("cstSource"));
                    customer.setCusName(customerJson.getString("name"));
                    customer.setAge(customerJson.getInteger("age"));
                    customer.setRemark(customerJson.getString("productName"));
                    customer.setPhone(customerJson.getString("phone"));
                    customer.setSex(customerJson.getInteger("sex") == 0 ? "女" : "男");
                    customer.setCityName(customerJson.getString("city"));

                    Optional.ofNullable(customerJson.getInteger("profession")).ifPresent(v -> {
                        switch (customerJson.getInteger("profession")) {
                            case 200:
                                customer.setWorks("上班族");
                                break;
                            case 300:
                                customer.setWorks("自由职业");
                                break;
                            case 400:
                                customer.setWorks("企业主");
                                break;
                            case 500:
                                customer.setWorks("个体户");
                                break;
                            case 800:
                                customer.setWorks("公务员");
                                break;
                            case 900:
                                customer.setWorks("其他");
                                break;
                        }

                    });

                    Optional.ofNullable(customerJson.getInteger("incomeMonth")).ifPresent(v -> {
                        customer.setIncomeMonth(customerJson.getInteger("incomeMonth")+"");
                    });



                    Optional.ofNullable(customerJson.getInteger("loanUse")).ifPresent(v -> {
                        switch (customerJson.getInteger("sesameScore")) {
                            case 0:
                                customer.setSesameScore("无芝麻分");
                                break;
                            case 10:
                                customer.setSesameScore("600分以下");
                                break;
                            case 20:
                                customer.setSesameScore("600~650分");
                                break;
                            case 30:
                                customer.setSesameScore("650~700分");
                                break;
                            case 40:
                                customer.setSesameScore("700分以上");
                                break;
                        }

                    });
                    Optional.ofNullable(customerJson.getString("loanMoney")).ifPresent(v -> {
                        customer.setAmount(customerJson.getString("loanMoney").substring(0, customerJson.getString(
                                "loanMoney").indexOf(".")) + "万元");
                    });

                    Optional.ofNullable(customerJson.getInteger("loanExpiresMonth")).ifPresent(v -> {
                        customer.setLoanExpiresMonth(customerJson.getInteger("loanExpiresMonth"));
                    });

                    Optional.ofNullable(customerJson.getInteger("loanUse")).ifPresent(v -> {
                        // 有值的处理逻辑
                        switch (customerJson.getInteger("loanUse")) {

                            case 10:
                                customer.setLoanUse("消费贷");
                                break;
                            case 20:
                                customer.setLoanUse("结婚贷");
                                break;
                            case 30:
                                customer.setLoanUse("购房贷");
                                break;
                            case 40:
                                customer.setLoanUse("装修贷");
                                break;
                            case 50:
                                customer.setLoanUse("购车贷");
                                break;
                            case 60:
                                customer.setLoanUse("教育贷");
                                break;
                            case 70:
                                customer.setLoanUse("旅游贷");
                                break;
                            case 80:
                                customer.setLoanUse("医疗贷");
                                break;
                            case 90:
                                customer.setLoanUse("其他贷");
                                break;
                        }
                    });

                    Optional.ofNullable(customerJson.getInteger("gjjScop")).ifPresent(v -> {

                        switch (customerJson.getInteger("gjjScop")) {
                            case 0:
                                customer.setAccumulation("无公积金");
                                break;
                            case 10:
                                customer.setAccumulation("缴纳未满6个月");
                                break;
                            case 20:
                                customer.setAccumulation("缴纳6个月以上");
                                break;
                        }
                    });


                    Optional.ofNullable(customerJson.getInteger("sbScop")).ifPresent(v -> {

                        switch (customerJson.getInteger("sbScop")) {
                            case 0:
                                customer.setSocial("无社保");
                                break;
                            case 10:
                                customer.setSocial("缴纳未满6个月");
                                break;
                            case 20:
                                customer.setSocial("缴纳6个月以上");
                                break;
                        }
                    });

                    Optional.ofNullable(customerJson.getInteger("house")).ifPresent(v -> {
                        switch (customerJson.getInteger("house")) {
                            case 0:
                                customer.setHouseType("无房产");
                                break;
                            case 10:
                                customer.setHouseType("有房产，不抵押");
                                break;
                            case 20:
                                customer.setHouseType("有房产，可抵押");
                                break;
                        }

                    });

                    Optional.ofNullable(customerJson.getInteger("car")).ifPresent(v -> {
                        switch (customerJson.getInteger("car")) {
                            case 0:
                                customer.setCarStatus("无车产");
                                break;
                            case 10:
                                customer.setCarStatus("有车产，不抵押");
                                break;
                            case 20:
                                customer.setCarStatus("有车产，可抵押");
                                break;
                        }

                    });

                    Optional.ofNullable(customerJson.getInteger("baodanScop")).ifPresent(v -> {

                        switch (customerJson.getInteger("baodanScop")) {
                            case 0:
                                customer.setBaodanScop("无保险保单");
                                break;
                            case 10:
                                customer.setBaodanScop("缴纳未满1年");
                                break;
                            case 20:
                                customer.setBaodanScop("缴纳1年以上");
                                break;
                        }
                    });
                    Optional.ofNullable(customerJson.getInteger("credit")).ifPresent(v -> {

                        switch (customerJson.getInteger("credit")) {
                            case 0:
                                customer.setZx("无信用记录");
                                break;
                            case 10:
                                customer.setZx("信用良好无逾期");
                                break;
                            case 20:
                                customer.setZx("2年内逾期少于9次无90天以上逾期");
                                break;
                            case 30:
                                customer.setZx("2年内逾期少于9次有90天以上逾期");
                                break;
                            case 40:
                                customer.setZx("2年内逾期大于9次");
                                break;
                            case 50:
                                customer.setZx("半年内有60天以上逾期");
                                break;
                            case 60:
                                customer.setZx("半年内无60天以上逾期");
                                break;
                        }
                    });
                    Optional.ofNullable(customerJson.getInteger("isLoans")).ifPresent(v -> {
                        switch (customerJson.getInteger("isLoans")) {
                            case 0:
                                customer.setIsLoans("无微粒贷");
                                break;
                            case 10:
                                customer.setIsLoans("1~2千");
                                break;
                            case 20:
                                customer.setIsLoans("2~5千");
                                break;
                            case 30:
                                customer.setIsLoans("5千~1万");
                                break;
                            case 40:
                                customer.setIsLoans("1万以上");
                                break;
                        }
                    });
                    Optional.ofNullable(customerJson.getInteger("manageYears")).ifPresent(v -> {
                        switch (customerJson.getInteger("manageYears")) {

                            case 10:
                                customer.setManageYears("1年以下");
                                break;
                            case 20:
                                customer.setManageYears("1年至5年");
                                break;
                            case 30:
                                customer.setManageYears("5年以上");
                                break;

                        }
                    });
                    Optional.ofNullable(customerJson.getString("turnover")).ifPresent(v -> {
                        customer.setTurnover(customerJson.getString("turnover"));
                    });
                    Optional.ofNullable(customerJson.getString("turnoverPublic")).ifPresent(v -> {
                        customer.setTurnoverPublic(customerJson.getString("turnoverPublic"));
                    });
                    Optional.ofNullable(customerJson.getInteger("workingYears")).ifPresent(v -> {
                        switch (customerJson.getInteger("workingYears")) {
                            case 10:
                                customer.setWorkingYears("0~6个月");
                                break;
                            case 20:
                                customer.setWorkingYears("6~12个月");
                                break;
                            case 30:
                                customer.setWorkingYears("12个月以上");
                                break;
                        }
                    });
                    Optional.ofNullable(customerJson.getInteger("registAddress")).ifPresent(v -> {
                        customer.setRegistAddress(customerJson.getInteger("registAddress") == 10 ? "本地" : "外地");
                    });
                    Optional.ofNullable(customerJson.getInteger("hasBusinessLicense")).ifPresent(v -> {
                        switch (customerJson.getInteger("hasBusinessLicense")) {
                            case 0:
                                customer.setHasBusinessLicense("未注册");
                                break;
                            case 10:
                                customer.setHasBusinessLicense("注册1年以下");
                                break;
                            case 20:
                                customer.setHasBusinessLicense("注册1至5年");
                                break;
                            case 30:
                                customer.setHasBusinessLicense("注册5年以上");
                                break;
                        }
                    });

                    Optional.ofNullable(customerJson.getInteger("creditCard")).ifPresent(v -> {
                        customer.setCreditCard(customerJson.getInteger("creditCard") == 0 ? "无信用卡" : "有信用卡");
                    });
                    Optional.ofNullable(customerJson.getString("apiSourceName")).ifPresent(v -> {
                        customer.setApiSourceName(customerJson.getString("apiSourceName"));
                    });
                    Optional.ofNullable(customerJson.getString("followUserName")).ifPresent(v -> {
                        customer.setFollowUserName(customerJson.getString("followUserName"));
                    });
                    Optional.ofNullable(customerJson.getString("brand")).ifPresent(v -> {
                        customer.setBrand(customerJson.getString("brand"));
                    });

                    Map map = customerService.savePushCustomer(customer);
                    if (map.get("code").equals("200")) {
                        String return_url = "https://gw.youxinsign.com/rxk-saas/api/organ-clue-api/updateClueStatus";
                        params = new JSONObject();
                        params.put("voucherCode", voucherCode);
                        params.put("orderNo", orderNo);
                        params.put("status", 1);
                        params.put("remark", map.get("message"));
                        returnJson = JSONObject.parseObject(HttpUtils.doPost(return_url, params));
                    }else{
                        returnJson.put("code",map.get("code"));
                        returnJson.put("message",map.get("message"));
                    }
                }
            }
        }

        rxkOrderService.save(rxkOrder);
        returnJson.put("code",200);
        returnJson.put("message","success");
       return returnJson;
    }


    /**
     * 吉客
     * @param params
     * @return
     */
    @Log(title = "吉客客户信息准入查询", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/customerIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map customerIsCheck(@RequestBody JSONObject params) {
        Map<String,Object> map=new HashMap<>();
        String merchantNo="H5394647689828";// 商户号
        if(!merchantNo.equals(params.getString("merchantNo"))){
            map.put("dealStatus","9999");
            map.put("dealDesc","商户号错误");
            return map;
        }
        String data=params.getString("data");// 加密的串
        String keyAes="f6c246d000e945a49dbd4e95d4887f46";
        try {
            // 解密
            data = Base64Util.decrypt(data, keyAes);

        }catch (Exception e){
            map.put("dealStatus","9999");
            map.put("dealDesc","data解密失败");
            return map;
        }
        JSONObject jsonObject=JSONObject.parseObject(data);
        if(StringUtils.isNull(jsonObject)){
            map.put("dealStatus","9999");
            map.put("dealDesc","data解密数据为空");
            return map;
        }
        if(null!=jsonObject){
            Customer customer=new Customer();
//            Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
//                customer.setCityName(jsonObject.getString("city").replace("市",""));
//            });
            Optional.ofNullable(jsonObject.getString("phoneNo")).ifPresent(v -> {
                customer.setPhoneMD5(jsonObject.getString("phoneNo"));
            });
            if(customerService.findCustomerByphone(customer)){
                map.put("dealStatus","9999");
                map.put("dealDesc","客户信息重复");
            }else{
                map.put("dealStatus","0000");
                map.put("dealDesc","客户可入库");
            }
        }
        return map;
    }

    /**
     * 吉客A
     * @param params
     * @return
     */
    @Log(title = "吉客A客户信息准入查询", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/customerJiKeOtherIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map customerJiKeOtherIsCheck(@RequestBody JSONObject params) {
        Map<String,Object> map=new HashMap<>();
        String merchantNo="H7181163174754";// 商户号
        if(!merchantNo.equals(params.getString("merchantNo"))){
            map.put("dealStatus","9999");
            map.put("dealDesc","商户号错误");
            return map;
        }
        String data=params.getString("data");// 加密的串
        String keyAes="f6c246d000e945a49dbd4e95d4887f46";
        try {
            // 解密
            data = Base64Util.decrypt(data, keyAes);

        }catch (Exception e){
            map.put("dealStatus","9999");
            map.put("dealDesc","data解密失败");
            return map;
        }
        JSONObject jsonObject=JSONObject.parseObject(data);
        if(StringUtils.isNull(jsonObject)){
            map.put("dealStatus","9999");
            map.put("dealDesc","data解密数据为空");
            return map;
        }
        if(null!=jsonObject){
            Customer customer=new Customer();
//            Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
//                customer.setCityName(jsonObject.getString("city").replace("市",""));
//            });
            Optional.ofNullable(jsonObject.getString("phoneNo")).ifPresent(v -> {
                customer.setPhoneMD5(jsonObject.getString("phoneNo"));
            });
            if(customerService.findCustomerByphone(customer)){
                map.put("dealStatus","9999");
                map.put("dealDesc","客户信息重复");
            }else{
                map.put("dealStatus","0000");
                map.put("dealDesc","客户可入库");
            }
        }
        return map;
    }

    /**
     * 吉客A
     * @param
     * @return
     */
    @Log(title = "吉客A客户信息推送", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/customerJiKeOtherInsert", method = RequestMethod.POST)
    @ResponseBody
    public Map customerJiKeOtherInsert(@RequestBody JSONObject params) {
        Map<String,Object> map=new HashMap<>();
        String merchantNo="H7181163174754";// 商户号
        if(!merchantNo.equals(params.getString("merchantNo"))){
            map.put("dealStatus","9999");
            map.put("dealDesc","商户号错误");
            return map;
        }
        String data=params.getString("data");// 加密的串

        String keyAes="f6c246d000e945a49dbd4e95d4887f46";
        try {
            // 解密
            data = Base64Util.decrypt(data, keyAes);
        }catch (Exception e){
            map.put("dealStatus","9999");
            map.put("dealDesc","data解密失败");
            return map;
        }
        JSONObject jsonObject=JSONObject.parseObject(data);
        if(StringUtils.isNull(jsonObject)){
            map.put("dealStatus","9999");
            map.put("dealDesc","data解密数据为空");
            return map;
        }
        if(null!=jsonObject){
            Customer customer=new Customer();
            customer.setLaiyuan("吉客A");
            Optional.ofNullable(jsonObject.getString("applyId")).ifPresent(v -> {
                customer.setClueId(jsonObject.getString("applyId"));
            });
            Optional.ofNullable(jsonObject.getString("custName")).ifPresent(v -> {
                customer.setCusName(jsonObject.getString("custName"));
            });
            Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                customer.setCityName(jsonObject.getString("city"));
            });
            Optional.ofNullable(jsonObject.getString("phoneNo")).ifPresent(v -> {
                customer.setPhone(jsonObject.getString("phoneNo"));
            });
            Optional.ofNullable(jsonObject.getString("sex")).ifPresent(v -> {
                switch (jsonObject.getString("sex")) {
                    case "1":
                        customer.setSex("男");
                        break;
                    case "2":
                        customer.setSex("女");
                        break;
                    default:
                        customer.setSex("未知");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("age")).ifPresent(v -> {
                customer.setAge(Integer.parseInt(jsonObject.getString("age")));
            });
            Optional.ofNullable(jsonObject.getString("loanAmount")).ifPresent(v -> {
                switch (jsonObject.getString("loanAmount")){
                    case "1":
                        customer.setAmount("0-3万");
                        break;
                    case "2":
                        customer.setAmount("3-5万");
                        break;
                    case "3":
                        customer.setAmount("5-10万");
                        break;
                    case "4":
                        customer.setAmount("10-20万");
                        break;
                    case "5":
                        customer.setAmount("20万以上");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("profession")).ifPresent(v -> {
                switch (jsonObject.getString("profession")){
                    case "1":
                        customer.setWorks("自由职业");
                        break;
                    case "2":
                        customer.setWorks("上班族");
                        break;
                    case "3":
                        customer.setWorks("个体户");
                        break;
                    case "4":
                        customer.setWorks("企业户");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("salaryType")).ifPresent(v -> {
                switch (jsonObject.getString("salaryType")){
                    case "1":
                        customer.setPayoffType("现金");
                        break;
                    case "2":
                        customer.setPayoffType("打卡工资");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("socialSecurity")).ifPresent(v -> {
                switch (jsonObject.getString("socialSecurity")){
                    case "1":
                        customer.setSocial("6个月下");
                        break;
                    case "2":
                        customer.setSocial("6个月上");
                        break;
                    case "0":
                        customer.setSocial("无");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("providentFund")).ifPresent(v -> {
                switch (jsonObject.getString("providentFund")){
                    case "1":
                        customer.setAccumulation("6个月下");
                        break;
                    case "2":
                        customer.setAccumulation("6个月上");
                        break;
                    case "0":
                        customer.setAccumulation("无");
                        break;
                }
            });

            Optional.ofNullable(jsonObject.getString("car")).ifPresent(v -> {
                switch (jsonObject.getString("car")){
                    case "1":
                        customer.setCarStatus("有按揭车");
                        break;
                    case "2":
                        customer.setCarStatus("有全款车");
                        break;
                    case "0":
                        customer.setCarStatus("无车");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("estate")).ifPresent(v -> {
                switch (jsonObject.getString("estate")){
                    case "1":
                        customer.setHouseType("有按揭商品房");
                        break;
                    case "2":
                        customer.setHouseType("有全款商品房");
                        break;
                    case "0":
                        customer.setHouseType("无房产");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("creditCardLimit")).ifPresent(v -> {
                switch (jsonObject.getString("creditCardLimit")){
                    case "1":
                        customer.setCreditCard("3000以下");
                        break;
                    case "2":
                        customer.setCreditCard("3000-5000元");
                        break;
                    case "3":
                        customer.setCreditCard("5000-10000元");
                        break;
                    case "4":
                        customer.setCreditCard("10000元以上");
                        break;
                    case "0":
                        customer.setCreditCard("无信用卡");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("zhiMaScore")).ifPresent(v -> {
                switch (jsonObject.getString("zhiMaScore")){
                    case "1":
                        customer.setSesameScore("600-650分");
                        break;
                    case "2":
                        customer.setSesameScore("650-700分");
                        break;
                    case "3":
                        customer.setSesameScore("700分以上");
                        break;
                    case "0":
                        customer.setSesameScore("无芝麻分");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("lifeInsurance")).ifPresent(v -> {
                switch (jsonObject.getString("lifeInsurance")){
                    case "1":
                        customer.setPolicy("有保单");
                        break;
                    case "0":
                        customer.setPolicy("无保单");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("monthIncome")).ifPresent(v -> {
                customer.setIncomeMonth(jsonObject.getString("monthIncome"));
            });

            Optional.ofNullable(jsonObject.getString("loanPurpose")).ifPresent(v -> {
                switch (jsonObject.getString("loanPurpose")){
                    case "1":
                        customer.setLoanUse("日常消费");
                        break;
                    case "2":
                        customer.setLoanUse("装修");
                        break;
                    case "3":
                        customer.setLoanUse("旅游");
                        break;
                    case "4":
                        customer.setLoanUse("教育培训");
                        break;
                    case "5":
                        customer.setLoanUse("婚庆");
                }
            });



            Optional.ofNullable(jsonObject.getString("fromIp")).ifPresent(v -> {
                 customer.setIp(jsonObject.getString("fromIp"));
            });
            Optional.ofNullable(jsonObject.getString("loanTerm")).ifPresent(v -> {
                String loanTerm="";
                switch (jsonObject.getString("loanTerm")){
                    case "01":
                        loanTerm="1年以内";
                        break;
                    case "02":
                        loanTerm="1-3年以内";
                        break;
                    case "03":
                        loanTerm="3年以上";
                        break;
                }
                customer.setRemark("借款周期："+loanTerm);
            });
            Optional.ofNullable(jsonObject.getString("degree")).ifPresent(v -> {
                String degree="";
                switch (jsonObject.getString("degree")){
                    case "1":
                        degree="高中及一下";
                        break;
                    case "2":
                        degree="大专";
                        break;
                    case "3":
                        degree="本科及以上";
                        break;
                }
                customer.setRemark(customer.getRemark()+"/学历："+degree);
            });
            Optional.ofNullable(jsonObject.getString("answeringTime")).ifPresent(v -> {
                String answeringTime=jsonObject.getString("answeringTime");
                customer.setRemark(customer.getRemark()+"/方便接听时间：："+answeringTime);
            });

            Map maps=customerService.savePushCustomer(customer);
            if(maps.get("code").equals("200")){
                map.put("dealStatus","0000");
            }else{
                map.put("dealStatus","9999");
                map.put("dealDesc",maps.get("message"));
            }
        }
        return map;
    }
    /**
     * 吉客
     * @param
     * @return
     */
    @Log(title = "吉客客户信息推送", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/customerJiKeInsert", method = RequestMethod.POST)
    @ResponseBody
    public Map customerJiKeInsert(@RequestBody JSONObject params) {
        Map<String,Object> map=new HashMap<>();
        String merchantNo="H5394647689828";// 商户号
        if(!merchantNo.equals(params.getString("merchantNo"))){
            map.put("dealStatus","9999");
            map.put("dealDesc","商户号错误");
            return map;
        }
        String data=params.getString("data");// 加密的串

        String keyAes="f6c246d000e945a49dbd4e95d4887f46";
        try {
            // 解密
            data = Base64Util.decrypt(data, keyAes);
        }catch (Exception e){
            map.put("dealStatus","9999");
            map.put("dealDesc","data解密失败");
            return map;
        }
        JSONObject jsonObject=JSONObject.parseObject(data);
        if(StringUtils.isNull(jsonObject)){
            map.put("dealStatus","9999");
            map.put("dealDesc","data解密数据为空");
            return map;
        }
        if(null!=jsonObject){
            Customer customer=new Customer();
            customer.setLaiyuan("吉客");
            Optional.ofNullable(jsonObject.getString("applyId")).ifPresent(v -> {
                customer.setClueId(jsonObject.getString("applyId"));
            });
            Optional.ofNullable(jsonObject.getString("custName")).ifPresent(v -> {
                customer.setCusName(jsonObject.getString("custName"));
            });
            Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                customer.setCityName(jsonObject.getString("city"));
            });
            Optional.ofNullable(jsonObject.getString("phoneNo")).ifPresent(v -> {
                customer.setPhone(jsonObject.getString("phoneNo"));
            });
            Optional.ofNullable(jsonObject.getString("sex")).ifPresent(v -> {
                switch (jsonObject.getString("sex")) {
                    case "1":
                        customer.setSex("男");
                        break;
                    case "2":
                        customer.setSex("女");
                        break;
                    default:
                        customer.setSex("未知");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("age")).ifPresent(v -> {
                customer.setAge(Integer.parseInt(jsonObject.getString("age")));
            });
            Optional.ofNullable(jsonObject.getString("loanAmount")).ifPresent(v -> {
                switch (jsonObject.getString("loanAmount")){
                    case "1":
                        customer.setAmount("0-3万");
                        break;
                    case "2":
                        customer.setAmount("3-5万");
                        break;
                    case "3":
                        customer.setAmount("5-10万");
                        break;
                    case "4":
                        customer.setAmount("10-20万");
                        break;
                    case "5":
                        customer.setAmount("20万以上");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("profession")).ifPresent(v -> {
                switch (jsonObject.getString("profession")){
                    case "1":
                        customer.setWorks("自由职业");
                        break;
                    case "2":
                        customer.setWorks("上班族");
                        break;
                    case "3":
                        customer.setWorks("个体户");
                        break;
                    case "4":
                        customer.setWorks("企业户");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("salaryType")).ifPresent(v -> {
                switch (jsonObject.getString("salaryType")){
                    case "1":
                        customer.setPayoffType("现金");
                        break;
                    case "2":
                        customer.setPayoffType("打卡工资");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("socialSecurity")).ifPresent(v -> {
                switch (jsonObject.getString("socialSecurity")){
                    case "1":
                        customer.setSocial("6个月下");
                        break;
                    case "2":
                        customer.setSocial("6个月上");
                        break;
                    case "0":
                        customer.setSocial("无");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("providentFund")).ifPresent(v -> {
                switch (jsonObject.getString("providentFund")){
                    case "1":
                        customer.setAccumulation("6个月下");
                        break;
                    case "2":
                        customer.setAccumulation("6个月上");
                        break;
                    case "0":
                        customer.setAccumulation("无");
                        break;
                }
            });

            Optional.ofNullable(jsonObject.getString("car")).ifPresent(v -> {
                switch (jsonObject.getString("car")){
                    case "1":
                        customer.setCarStatus("有按揭车");
                        break;
                    case "2":
                        customer.setCarStatus("有全款车");
                        break;
                    case "0":
                        customer.setCarStatus("无车");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("estate")).ifPresent(v -> {
                switch (jsonObject.getString("estate")){
                    case "1":
                        customer.setHouseType("有按揭商品房");
                        break;
                    case "2":
                        customer.setHouseType("有全款商品房");
                        break;
                    case "0":
                        customer.setHouseType("无房产");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("creditCardLimit")).ifPresent(v -> {
                switch (jsonObject.getString("creditCardLimit")){
                    case "1":
                        customer.setCreditCard("3000以下");
                        break;
                    case "2":
                        customer.setCreditCard("3000-5000元");
                        break;
                    case "3":
                        customer.setCreditCard("5000-10000元");
                        break;
                    case "4":
                        customer.setCreditCard("10000元以上");
                        break;
                    case "0":
                        customer.setCreditCard("无信用卡");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("zhiMaScore")).ifPresent(v -> {
                switch (jsonObject.getString("zhiMaScore")){
                    case "1":
                        customer.setSesameScore("600-650分");
                        break;
                    case "2":
                        customer.setSesameScore("650-700分");
                        break;
                    case "3":
                        customer.setSesameScore("700分以上");
                        break;
                    case "0":
                        customer.setSesameScore("无芝麻分");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("lifeInsurance")).ifPresent(v -> {
                switch (jsonObject.getString("lifeInsurance")){
                    case "1":
                        customer.setPolicy("有保单");
                        break;
                    case "0":
                        customer.setPolicy("无保单");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("monthIncome")).ifPresent(v -> {
                customer.setIncomeMonth(jsonObject.getString("monthIncome"));
            });
            Optional.ofNullable(jsonObject.getString("carNum")).ifPresent(v -> {
                customer.setCarNo(jsonObject.getString("carNum"));
            });

            Optional.ofNullable(jsonObject.getString("loanPurpose")).ifPresent(v -> {
                switch (jsonObject.getString("loanPurpose")){
                    case "1":
                        customer.setLoanUse("日常消费");
                        break;
                    case "2":
                        customer.setLoanUse("装修");
                        break;
                    case "3":
                        customer.setLoanUse("旅游");
                        break;
                    case "4":
                        customer.setLoanUse("教育培训");
                        break;
                    case "5":
                        customer.setLoanUse("婚庆");
                    }
            });

            Optional.ofNullable(jsonObject.getString("carAge")).ifPresent(v -> {
                switch (jsonObject.getString("carAge")){
                    case "1":
                        customer.setCarAge("10年以内");
                        break;
                    case "2":
                        customer.setCarAge("10年以上");
                        break;
                }
            });

            Optional.ofNullable(jsonObject.getString("carCost")).ifPresent(v -> {
                switch (jsonObject.getString("carCost")){
                    case "1":
                        customer.setPgPrice("3万以下");
                        break;
                    case "2":
                        customer.setCarAge("3-10万");
                        break;
                    case "3":
                        customer.setCarAge("10万以上");
                        break;
                }
            });
            Map maps=customerService.savePushCustomer(customer);
            if(maps.get("code").equals("200")){
                map.put("dealStatus","0000");
            }else{
                map.put("dealStatus","9999");
                map.put("dealDesc",maps.get("message"));
            }
        }
        return map;
    }


    /**
     * 已接通 16 惠融
     * @param param
     * @return
     */
    @Log(title = "客户推送信息-惠融", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByHuiRong", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByHuiRong(@RequestBody JSONObject param) throws Exception {
        Map map=new HashMap();
        if(StringUtils.isNotEmpty(param.getString("data"))){
            String dataRes= AESUtils.Decrypt(param.getString("data"),"kzhtybx8qzmjrc06");
            JSONObject jsonObject=JSONObject.parseObject(dataRes);
            if(null!=jsonObject){
                Customer customer=new Customer();
                customer.setAmount(jsonObject.getString("amount"));
                customer.setCityName(jsonObject.getString("cityName"));
                customer.setCarStatus(jsonObject.getString("carStatus"));
                customer.setCusName(jsonObject.getString("cusName"));
                customer.setPhone(jsonObject.getString("phone"));
                customer.setCarModel(jsonObject.getString("carModel"));
                customer.setCarAge(jsonObject.getString("carAge"));
                customer.setCusCanal(jsonObject.getString("dc"));
                customer.setRemark(jsonObject.getString("remark"));
                customer.setLaiyuan("惠融");
                return customerService.savePushCustomer(customer);
            }else {
                map.put("code","500");
                map.put("message","json is error");
            }
        }else{

            map.put("code","500");
            map.put("message","data is null");

        }
        return map;
    }


    /**
     * 已接通 16 惠融撞库
     * @param param
     * @return
     */
    @Log(title = "客户推送信息-惠融撞库", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByHuiRongIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByHuiRongIsCheck(@RequestBody JSONObject param) throws Exception {

        Map map=new HashMap();
        if(StringUtils.isNotEmpty(param.getString("data"))){
            String dataRes= AESUtils.Decrypt(param.getString("data"),"kzhtybx8qzmjrc06");
            JSONObject jsonObject=JSONObject.parseObject(dataRes);
            if(null!=jsonObject){
                Customer customer=new Customer();
                customer.setPhone(jsonObject.getString("phone"));
                if(customerService.findCustomerByphone(customer)){
                    map.put("code","201");
                    map.put("message","客户存在，不准入");
                }else {
                    map.put("code","200");
                    map.put("message","准入客户");
                }
            }else {
                map.put("code","500");
                map.put("message","json is error");
            }
        }else{

            map.put("code","500");
            map.put("message","data is null");

        }
        return map;
    }

    /**
     * 融享客
     * @param param
     * @return
     */
    @Log(title = "客户推送信息-撞库接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRongXiangKeIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRongXiangKeIsCheck(@RequestBody JSONObject param) throws Exception {

        Map map=new HashMap();
        if(StringUtils.isNotEmpty(param.getString("phone"))){
            String phone= RongXiangKeAESUtil.decrypt(param.getString("phone"), RongXiangKeAESUtil.KEY);
            phone=phone.substring(0, 8);
            Customer customer=new Customer();
            customer.setPhone(phone);
            List<Customer> customers=customerService.findList(customer);
            List<String> list=new ArrayList<>();
            for (Customer cus : customers){
                list.add(Md5Utils.hash(cus.getPhone()));
            }
            map.put("code",200);
            map.put("data",list);
            map.put("msg","成功");
            return map;
        }else{
            map.put("code","401");
            map.put("msg","phone is null");
        }
        return map;
    }

    /**
     * 橙易通A
     * @param param
     * @return
     */
    @Log(title = "橙易通A客户推送信息-撞库接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByCytIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByCytIsCheck(@RequestBody JSONObject param) throws Exception {

        Map map=new HashMap();
        if(StringUtils.isNotEmpty(param.getString("data"))){
            String phone= AESUtils.Decrypt(param.getString("data"),"hbt4j8ql7n7yjtfb");
            if(null==phone){
                map.put("code","401");
                map.put("msg","data is null");
                return map;
            }
            JSONObject jsonObject=JSONObject.parseObject(phone);
            if(null!=jsonObject){
                phone=jsonObject.getString("phone");
            }else{
                map.put("code","401");
                map.put("msg","data is null");
                return map;
            }
            phone=phone.substring(0, 8);
            Customer customer=new Customer();
            customer.setPhone(phone);
            List<Customer> customers=customerService.findList(customer);
            List<String> list=new ArrayList<>();
            for (Customer cus : customers){
                list.add(Md5Utils.hash(cus.getPhone()));
            }
            map.put("code",200);
            map.put("data",list);
            map.put("msg","成功");
            return map;
        }else{
            map.put("code","401");
            map.put("msg","phone is null");
        }
        return map;
    }

    /**
     * 橙易通A
     * @param param
     * @return
     */
    @Log(title = "橙易通A客户推送信息-推送接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByCytPush", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByCytPush(@RequestBody JSONObject param) throws Exception {
        Map map=new HashMap();
        if(StringUtils.isNotEmpty(param.getString("data"))){
            String json= AESUtils.Decrypt(param.getString("data"),"hbt4j8ql7n7yjtfb");
            if(null==json){
                map.put("code","401");
                map.put("msg","data is null");
                return map;
            }
            JSONObject jsonObject=JSONObject.parseObject(json);
            if(null!=jsonObject){
               Customer customer=new Customer();
               customer.setLaiyuan("橙易通A");
                Optional.ofNullable(jsonObject.getString("name")).ifPresent(v -> {
                    customer.setCusName(v);
                });
                Optional.ofNullable(jsonObject.getString("phone")).ifPresent(v -> {
                    customer.setPhone(v);
                });
                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(v -> {
                    customer.setAge(v);
                });
                Optional.ofNullable(jsonObject.getString("gender")).ifPresent(v -> {
                    customer.setSex(v);
                });
                Optional.ofNullable(jsonObject.getString("ip")).ifPresent(v -> {
                    customer.setIp(v);
                });
                Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                    customer.setCityName(v);
                });
                Optional.ofNullable(jsonObject.getInteger("profession")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setWorks("上班族");
                            break;
                        case 2:
                            customer.setWorks("自由职业");
                            break;
                        case 3:
                            customer.setWorks("企业主");
                            break;
                        case 4:
                            customer.setWorks("公务员/国企");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("loanAmount")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setAmount("3万-5万");
                            break;
                        case 2:
                            customer.setAmount("5万-10万");
                            break;
                        case 3:
                            customer.setAmount("10万-20万");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("sesameSeed")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setSesameScore("700以上");
                            break;
                        case 2:
                            customer.setSesameScore("650-700");
                            break;
                        case 3:
                            customer.setSesameScore("600-650");
                            break;
                        case 4:
                            customer.setSesameScore("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("socialSecurity")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setSocial("6个月以下");
                            break;
                        case 2:
                            customer.setSocial("6-12个月");
                            break;
                        case 3:
                            customer.setSocial("12个月以上");
                            break;
                        case 4:
                            customer.setSocial("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("providentFund")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setAccumulation("6个月以下");
                            break;
                        case 2:
                            customer.setAccumulation("6-12个月");
                            break;
                        case 3:
                            customer.setAccumulation("12个月以上");
                            break;
                        case 4:
                            customer.setAccumulation("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("providentFund")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setAccumulation("6个月以下");
                            break;
                        case 2:
                            customer.setAccumulation("6-12个月");
                            break;
                        case 3:
                            customer.setAccumulation("12个月以上");
                            break;
                        case 4:
                            customer.setAccumulation("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("vehicle")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setCarStatus("有");
                            break;
                        case 2:
                            customer.setCarStatus("无");
                            break;


                    }
                });
                Optional.ofNullable(jsonObject.getInteger("house")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setHouseType("有");
                            break;
                        case 2:
                            customer.setHouseType("无");
                            break;


                    }
                });
                customerService.savePushCustomer(customer);

                map.put("code",200);
                map.put("msg","进件成功");
                return map;
            }else{
                map.put("code","401");
                map.put("msg","data is null");
                return map;
            }

        }else{
            map.put("code","401");
            map.put("msg","phone is null");
        }
        return map;
    }

    /**
     * 橙易通
     * @param param
     * @return
     */
    @Log(title = "橙易通客户推送信息-推送接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByCytNextPush", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByCytNextPush(@RequestBody JSONObject param) throws Exception {
        Map map=new HashMap();
        if(StringUtils.isNotEmpty(param.getString("data"))){
            String json= AESUtils.Decrypt(param.getString("data"),"hbt4j8ql7n7yjtfb");
            if(null==json){
                map.put("code","401");
                map.put("msg","data is null");
                return map;
            }
            JSONObject jsonObject=JSONObject.parseObject(json);
            if(null!=jsonObject){
                Customer customer=new Customer();
                customer.setLaiyuan("橙易通CYT");
                Optional.ofNullable(jsonObject.getString("name")).ifPresent(v -> {
                    customer.setCusName(v);
                });
                Optional.ofNullable(jsonObject.getString("phone")).ifPresent(v -> {
                    customer.setPhone(v);
                });
                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(v -> {
                    customer.setAge(v);
                });
                Optional.ofNullable(jsonObject.getString("gender")).ifPresent(v -> {
                    customer.setSex(v);
                });
                Optional.ofNullable(jsonObject.getString("ip")).ifPresent(v -> {
                    customer.setIp(v);
                });
                Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                    customer.setCityName(v);
                });
                Optional.ofNullable(jsonObject.getInteger("profession")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setWorks("上班族");
                            break;
                        case 2:
                            customer.setWorks("自由职业");
                            break;
                        case 3:
                            customer.setWorks("企业主");
                            break;
                        case 4:
                            customer.setWorks("公务员/国企");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("loanAmount")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setAmount("3万-5万");
                            break;
                        case 2:
                            customer.setAmount("5万-10万");
                            break;
                        case 3:
                            customer.setAmount("10万-20万");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("sesameSeed")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setSesameScore("700以上");
                            break;
                        case 2:
                            customer.setSesameScore("650-700");
                            break;
                        case 3:
                            customer.setSesameScore("600-650");
                            break;
                        case 4:
                            customer.setSesameScore("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("socialSecurity")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setSocial("6个月以下");
                            break;
                        case 2:
                            customer.setSocial("6-12个月");
                            break;
                        case 3:
                            customer.setSocial("12个月以上");
                            break;
                        case 4:
                            customer.setSocial("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("providentFund")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setAccumulation("6个月以下");
                            break;
                        case 2:
                            customer.setAccumulation("6-12个月");
                            break;
                        case 3:
                            customer.setAccumulation("12个月以上");
                            break;
                        case 4:
                            customer.setAccumulation("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("providentFund")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setAccumulation("6个月以下");
                            break;
                        case 2:
                            customer.setAccumulation("6-12个月");
                            break;
                        case 3:
                            customer.setAccumulation("12个月以上");
                            break;
                        case 4:
                            customer.setAccumulation("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("vehicleMortgageStatus")).ifPresent(v -> {
                    switch (v){
                        case 0:
                            customer.setCarStatus("未抵押");
                            break;
                        case 1:
                            customer.setCarStatus("无按揭中");
                            break;


                    }
                });
                Optional.ofNullable(jsonObject.getInteger("house")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setHouseType("有");
                            break;
                        case 2:
                            customer.setHouseType("无");
                            break;


                    }
                });
                Optional.ofNullable(jsonObject.getInteger("vehicleMortgage")).ifPresent(v -> {
                    switch (v){
                        case 0:
                            customer.setCarModel("不可抵押");
                            break;
                        case 1:
                            customer.setCarModel("可抵押");
                            break;


                    }
                });
                Optional.ofNullable(jsonObject.getInteger("vehicleTime")).ifPresent(v -> {
                    switch (v){
                        case 1:
                            customer.setCarAge("10年以下");
                            break;
                        case 2:
                            customer.setCarModel("10年以上");
                            break;


                    }
                });
                Optional.ofNullable(jsonObject.getString("vehicleCity")).ifPresent(v -> {
                   customer.setCarNo(v);
                });


                customerService.savePushCustomer(customer);

                map.put("code",200);
                map.put("msg","进件成功");
                return map;
            }else{
                map.put("code","401");
                map.put("msg","data is null");
                return map;
            }

        }else{
            map.put("code","401");
            map.put("msg","phone is null");
        }
        return map;
    }

    /**
     * 橙易通
     * @param param
     * @return
     */
    @Log(title = "橙易通客户推送信息-撞库接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByCytNextIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByCytNextIsCheck(@RequestBody JSONObject param) throws Exception {

        Map map=new HashMap();
        if(StringUtils.isNotEmpty(param.getString("data"))){
            String phone= AESUtils.Decrypt(param.getString("data"),"hbt4j8ql7n7yjtfb");
            if(null==phone){
                map.put("code","401");
                map.put("msg","data is null");
                return map;
            }
            JSONObject jsonObject=JSONObject.parseObject(phone);
            if(null!=jsonObject){
                phone=jsonObject.getString("phone");
            }else{
                map.put("code","401");
                map.put("msg","data is null");
                return map;
            }
            phone=phone.substring(0, 8);
            Customer customer=new Customer();
            customer.setPhone(phone);
            List<Customer> customers=customerService.findList(customer);
            List<String> list=new ArrayList<>();
            for (Customer cus : customers){
                list.add(Md5Utils.hash(cus.getPhone()));
            }

            map.put("code",200);
            map.put("data",list);
            map.put("msg","成功");
            return map;
        }else{
            map.put("code","401");
            map.put("msg","phone is null");
        }
        return map;
    }


    /**
     * 融享客-线索通知
     * @param param
     * @return
     */
    @Log(title = "客户推送信息-线索通知", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRongXiangKeOrder", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRongXiangKeOrder(@RequestBody JSONObject param) throws Exception {
        Map map=new HashMap();
        if(StringUtils.isNotEmpty(param.getString("orderNo"))){
            String orderNo=param.getString("orderNo");
            RxkOrder rxkOrder=new RxkOrder();
            rxkOrder.setId(orderNo);
            rxkOrder.setIsNewRecord();
            rxkOrder.setOrderNo(orderNo);
            rxkOrder.setStatus("0");
            try{
                int count =customerService.insertRongXinKe(rxkOrder.getOrderNo());
                if(count==1){
                    if(rxkOrderService.save(rxkOrder)){
                        map.put("code",200);
                        map.put("msg","通知成功");
                    }else {
                        map.put("code",500);
                        map.put("msg","通知失败");
                    }
                }else{
                    map.put("code",500);
                    map.put("msg","获取消息失败");
                }

            }catch (Exception e){
                map.put("code",500);
                map.put("msg","通知失败:"+e.getMessage());
            }
            return map;
        }else{
            map.put("code","401");
            map.put("msg","orderNo is null");
        }
        return map;
    }

    /**
     * 乐数云客户推送信息 1
     * @param jsonObjects
     * @return
     */
    @Log(title = "乐数云客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertLeShuYun", method = RequestMethod.POST)
    @ResponseBody
    public Map insertLeShuYun(@RequestBody JSONObject[] jsonObjects) {
        Map  map=new HashMap();
        List<Map> maps=new ArrayList<>();
        for (int i=0;i<jsonObjects.length;i++) {
            Customer customer=new Customer();
            customer.setLaiyuan("乐数云");
            JSONObject jsonObject=jsonObjects[i];
            Optional.ofNullable(jsonObject.getString("id")).ifPresent(v -> {
                 customer.setClueId(v);
            });
            Optional.ofNullable(jsonObject.getString("name")).ifPresent(v -> {
                customer.setCusName(v);
            });
            Optional.ofNullable(jsonObject.getString("mobile")).ifPresent(v -> {
                customer.setPhone(v);
            });
            Optional.ofNullable(jsonObject.getString("expectedAmount")).ifPresent(v -> {
                customer.setAmount(v);
            });
            Optional.ofNullable(jsonObject.getString("launchPlatform")).ifPresent(v -> {
                customer.setRemark(v);
            });
            Optional.ofNullable(jsonObject.getString("situation")).ifPresent(v -> {
                customer.setRemark(customer.getRemark()+"/"+v);
            });
            Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                customer.setCityName(v);
            });
            maps.add( customerService.savePushCustomer(customer));
        }
        map.put("maps",maps);
        return map;
    }

    /**
     * 融360 撞库
     * @param
     * @return
     */
    @Log(title = "融360撞库", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360IsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360IsCheck(String channel_code,String mobile,String sign,String timestamp) throws Exception {
        Map  map=new HashMap();
        if(StringUtils.isNotEmpty(channel_code)&&"rong360".equals(channel_code)){
            String phone= new String(Rong360Codec.base64StrDecode("mWgiBgxlKX6Qvq9v","BgBk0REx0Gx1yIgk",mobile));
            phone=phone.substring(0, 7);
            Customer customer=new Customer();
            customer.setPhone(phone);
            List<Customer> customers=customerService.findList(customer);
            if (customers.size()>0){
                List<String> list=new ArrayList<>();
                for (Customer cus : customers){
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code",1);
                map.put("data",list);
                map.put("msg","success");
            }else{
                map.put("code",0);
                map.put("data",null);
                map.put("msg","fail");
            }

        }else{
            map.put("msg","channel_code is error");
            map.put("code",-1);
        }
        return map;
    }
    /**
     * 融360 撞库
     * @param
     * @return
     */
    @Log(title = "融360撞库-宁波", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360ShangRaoIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360ShangRaoIsCheck(String channel_code,String mobile,String sign,String timestamp) throws Exception {
        Map  map=new HashMap();
        if(StringUtils.isNotEmpty(channel_code)&&"rong360".equals(channel_code)){
            String phone= new String(Rong360Codec.base64StrDecode("8wf4r2EODCQY7z0F","shZU7uNUubQx1F6w",mobile));
            phone=phone.substring(0, 7);
            Customer customer=new Customer();
            customer.setPhone(phone);
            List<Customer> customers=customerService.findList(customer);
            if (customers.size()>0){
                List<String> list=new ArrayList<>();
                for (Customer cus : customers){
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code",1);
                map.put("data",list);
                map.put("msg","success");
            }else{
                map.put("code",0);
                map.put("data",null);
                map.put("msg","fail");
            }

        }else{
            map.put("msg","channel_code is error");
            map.put("code",-1);
        }
        return map;
    }

    /**
     * 融360 撞库
     * @param
     * @return
     */
    @Log(title = "融360撞库-吉安", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360JiAnIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360JiAnIsCheck(String channel_code,String mobile,String sign,String timestamp) throws Exception {
        Map  map=new HashMap();
        if(StringUtils.isNotEmpty(channel_code)&&"rong360".equals(channel_code)){
            String phone= new String(Rong360Codec.base64StrDecode("6ZxOehDCBq9mNgfy","AkM3FmTHCjhHM7wh",mobile));
            phone=phone.substring(0, 7);
            Customer customer=new Customer();
            customer.setPhone(phone);
            List<Customer> customers=customerService.findList(customer);
            if (customers.size()>0){
                List<String> list=new ArrayList<>();
                for (Customer cus : customers){
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code",1);
                map.put("data",list);
                map.put("msg","success");
            }else{
                map.put("code",0);
                map.put("data",null);
                map.put("msg","fail");
            }

        }else{
            map.put("msg","channel_code is error");
            map.put("code",-1);
        }
        return map;
    }


    /**
     * 融360 撞库
     * @param
     * @return
     */
    @Log(title = "融360撞库-抚州", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360FuZhouIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360FuZhouIsCheck(String channel_code,String mobile,String sign,String timestamp) throws Exception {
        Map  map=new HashMap();
        if(StringUtils.isNotEmpty(channel_code)&&"rong360".equals(channel_code)){
            String phone= new String(Rong360Codec.base64StrDecode("MMPFMHKaowMLKya9","PAceFq15yBKVsgzX",mobile));
            phone=phone.substring(0, 7);
            Customer customer=new Customer();
            customer.setPhone(phone);
            List<Customer> customers=customerService.findList(customer);
            if (customers.size()>0){
                List<String> list=new ArrayList<>();
                for (Customer cus : customers){
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code",1);
                map.put("data",list);
                map.put("msg","success");
            }else{
                map.put("code",0);
                map.put("data",null);
                map.put("msg","fail");
            }

        }else{
            map.put("msg","channel_code is error");
            map.put("code",-1);
        }
        return map;
    }

    /**
     * 融360 撞库
     * @param
     * @return
     */
    @Log(title = "融360撞库-九江", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360JiuJiangIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360JiuJiangIsCheck(String channel_code,String mobile,String sign,String timestamp) throws Exception {
        Map  map=new HashMap();
        if(StringUtils.isNotEmpty(channel_code)&&"rong360".equals(channel_code)){
            String phone= new String(Rong360Codec.base64StrDecode("tyDXaN5ZS80uJ08Z","k8E2eDtgylFluNHM",mobile));
            phone=phone.substring(0, 7);
            Customer customer=new Customer();
            customer.setPhone(phone);
            List<Customer> customers=customerService.findList(customer);
            if (customers.size()>0){
                List<String> list=new ArrayList<>();
                for (Customer cus : customers){
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code",1);
                map.put("data",list);
                map.put("msg","success");
            }else{
                map.put("code",0);
                map.put("data",null);
                map.put("msg","fail");
            }

        }else{
            map.put("msg","channel_code is error");
            map.put("code",-1);
        }
        return map;
    }
    /**
     * 融360 撞库
     * @param
     * @return
     */
    @Log(title = "融360撞库-赣州", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360GanZhouIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360GanZhouIsCheck(String channel_code,String mobile,String sign,String timestamp) throws Exception {
        Map  map=new HashMap();
        if(StringUtils.isNotEmpty(channel_code)&&"rong360".equals(channel_code)){
            String phone= new String(Rong360Codec.base64StrDecode("ShUYftzv0o1Y6xxB","HIoyqF1OBh8zdQVJ",mobile));
            phone=phone.substring(0, 7);
            Customer customer=new Customer();
            customer.setPhone(phone);
            List<Customer> customers=customerService.findList(customer);
            if (customers.size()>0){
                List<String> list=new ArrayList<>();
                for (Customer cus : customers){
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code",1);
                map.put("data",list);
                map.put("msg","success");
            }else{
                map.put("code",0);
                map.put("data",null);
                map.put("msg","fail");
            }

        }else{
            map.put("msg","channel_code is error");
            map.put("code",-1);
        }
        return map;
    }

    /**
     * 融360 撞库
     * @param
     * @return
     */
    @Log(title = "融360撞库-宜春", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360YiChunIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360YiChunIsCheck(String channel_code,String mobile,String sign,String timestamp) throws Exception {
        Map  map=new HashMap();
        if(StringUtils.isNotEmpty(channel_code)&&"rong360".equals(channel_code)){
            String phone= new String(Rong360Codec.base64StrDecode("YrvxrAVK6Kl9gmkX","tglJ7bKr5gBoIXWN",mobile));
            phone=phone.substring(0, 7);
            Customer customer=new Customer();
            customer.setPhone(phone);
            List<Customer> customers=customerService.findList(customer);
            if (customers.size()>0){
                List<String> list=new ArrayList<>();
                for (Customer cus : customers){
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code",1);
                map.put("data",list);
                map.put("msg","success");
            }else{
                map.put("code",0);
                map.put("data",null);
                map.put("msg","fail");
            }

        }else{
            map.put("msg","channel_code is error");
            map.put("code",-1);
        }
        return map;
    }
    /**
     * 已接通 10 通用
     * @param customer
     * @return
     */
    @Log(title = "群德客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerQunDe", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerQunDe(@RequestBody Customer customer) {
        String city=customer.getCityName();
        String citys[]=city.split("-");
        if (citys.length==2){
            customer.setCityName(citys[1].replace("市",""));
        }else{
            customer.setCityName(city.replace("市",""));
        }
        return customerService.savePushCustomer(customer);
    }



    @Log(title = "码小米-撞库接口", businessType = BusinessType.CHECK)
    @RequestMapping(value = "/api/check", method = RequestMethod.POST)
    @ResponseBody
    public Map MxmCheck(@RequestBody JSONObject param) throws Exception {
        String keyAes="tyDXaN5ZS80uJ08Z";
        String channelCode="CLQ20250000017";
        Map<String,Object> resultMap=new HashMap<>();
        if(StringUtils.isNotEmpty(param.getString("channelCode"))&&channelCode.equals(param.getString("channelCode"))){
            String data =param.getString("data");
            JSONObject jsonObject=null;
            try{
                 jsonObject = JSONObject.parseObject(AesMxmUtils.decrypt(data, keyAes));
            }catch (Exception e){
                resultMap.put("code",-1);
                resultMap.put("msg","解密失败");
                return resultMap;
            }
            if(StringUtils.isNotEmpty(jsonObject.getString("phoneMask"))){
                Customer customer=new Customer();
                customer.setPhone(jsonObject.getString("phoneMask"));
                List<Customer> customers=customerService.findList(customer);
                List<String> list=new ArrayList<>();
                for (Customer cus : customers){
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                resultMap.put("code",0);
                resultMap.put("data",list);
                resultMap.put("msg","成功");
            }else{
                resultMap.put("code",-1);
                resultMap.put("msg","phone is null");
            }
        }else{
            resultMap.put("code",-1);
            resultMap.put("msg","channel_code is error or is null");
        }
        return resultMap;
    }


    @Log(title = "码小米-进件", businessType = BusinessType.CHECK)
    @RequestMapping(value = "/api/apply", method = RequestMethod.POST)
    @ResponseBody
    public Map MxmApply(@RequestBody JSONObject param) throws Exception {
        String keyAes="tyDXaN5ZS80uJ08Z";
        String channelCode="CLQ20250000017";
        Map<String,Object> resultMap=new HashMap<>();
        if(StringUtils.isNotEmpty(param.getString("channelCode"))&&channelCode.equals(param.getString("channelCode"))){
            String data =param.getString("data");
            JSONObject jsonObject=null;
            try{
                jsonObject = JSONObject.parseObject(AesMxmUtils.decrypt(data, keyAes));
                Customer customer=new Customer();
                Optional.ofNullable(jsonObject.getString("name")).ifPresent(v -> {
                    customer.setCusName(v);
                });
                Optional.ofNullable(jsonObject.getString("phone")).ifPresent(v -> {
                    customer.setPhone(v);
                });
                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(v -> {
                    customer.setAge(v);
                });
                Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                    customer.setCityName(v.replace("市",""));
                });
                Optional.ofNullable(jsonObject.getInteger("sex")).ifPresent(v -> {
                    customer.setSex(v==1?"男":"女");
                });
                Optional.ofNullable(jsonObject.getInteger("loanAmount")).ifPresent(v -> {
                    customer.setAmount(v+"");
                });

                Optional.ofNullable(jsonObject.getInteger("occupation")).ifPresent(v -> {
                    String occupation="";
                    switch (v){
                        case 1:
                            occupation="上班族";
                            break;
                            case 5:
                            occupation="自由职业";
                            break;
                            case 2:
                            occupation="企业主";
                            break;
                            case 3:
                            occupation="个体户";
                            break;
                            case 4:
                            occupation="事业单位/公务员";
                            break;
                    }
                    customer.setWorks(occupation);
                });
                Optional.ofNullable(jsonObject.getInteger("salaryMethod")).ifPresent(v -> {
                   String salaryMethod="";
                   switch (v){
                       case 1:
                           salaryMethod="银行代发";
                           break;
                           case 2:
                           salaryMethod="微信支付宝";
                           break;
                           case 3:
                           salaryMethod="现金发放";
                           break;
                   }
                   customer.setPayoffType(salaryMethod);
                });
                Optional.ofNullable(jsonObject.getInteger("salaryMoney")).ifPresent(v -> {
                    String salaryMoney="";
                    switch (v){
                        case 1:
                            salaryMoney="1万及以上";
                            break;
                        case 2:
                            salaryMoney="5千-1万";
                            break;
                        case 3:
                            salaryMoney="5千以内";
                            break;
                    }
                    customer.setIncomeMonth(salaryMoney);
                });
                Optional.ofNullable(jsonObject.getInteger("workAge")).ifPresent(v -> {
                    String workAge="";
                    switch (v){
                        case 1:
                            workAge="12个月及以上";
                            break;
                        case 2:
                            workAge="6-12个月";
                            break;
                        case 3:
                            workAge="0-6个月";
                            break;
                    }
                    customer.setWorkingYears(workAge);
                });
                Optional.ofNullable(jsonObject.getInteger("companyMoney")).ifPresent(v -> {
                    String companyMoney="";
                    switch (v){
                        case 1:
                            companyMoney="10-50万";
                            break;
                        case 2:
                            companyMoney="50-100万";
                            break;
                        case 3:
                            companyMoney="100-300万";
                            break;
                        case 4:
                            companyMoney="300万及以上";
                            break;
                            case 5:
                            companyMoney="10万以内";
                            break;
                    }
                    customer.setTurnoverPublic(companyMoney);
                });
                Optional.ofNullable(jsonObject.getInteger("socialInsurance")).ifPresent(v -> {
                    String socialInsurance="";
                    switch (v){
                        case 1:
                            socialInsurance="缴纳6个月以上";
                            break;
                        case 2:
                            socialInsurance="缴纳未满6个月";
                            break;
                            case 3:
                            socialInsurance="无社保";
                            break;
                    }
                    customer.setSocial(socialInsurance);
                });
                Optional.ofNullable(jsonObject.getInteger("houseFund")).ifPresent(v -> {
                    String houseFund="";
                    switch (v){
                        case 1:
                            houseFund="缴纳6个月以上";
                            break;
                        case 2:
                            houseFund="缴纳未满6个月";
                            break;
                            case 3:
                            houseFund="无公积金";
                            break;
                    }
                    customer.setAccumulation(houseFund);
                });
                Optional.ofNullable(jsonObject.getInteger("house")).ifPresent(v -> {
                    String house="";
                    switch (v){
                        case 1:
                            house="有全款房";
                            break;
                        case 2:
                            house="有按揭房";
                            break;
                        case 3:
                            house="无房";
                            break;
                    }
                    customer.setHouseType(house);
                });
                Optional.ofNullable(jsonObject.getInteger("car")).ifPresent(v -> {
                    String car="";
                    switch (v){
                        case 1:
                            car="有全款车";
                            break;
                        case 2:
                            car="有按揭车";
                            break;
                        case 3:
                            car="无车产";
                            break;
                    }
                    customer.setCarStatus(car);
                });
                Optional.ofNullable(jsonObject.getInteger("lifeInsurance")).ifPresent(v -> {
                    String lifeInsurance="";
                    switch (v){
                        case 1:
                            lifeInsurance="缴纳2年以上";
                            break;
                        case 2:
                            lifeInsurance="缴纳1年以上";
                            break;
                        case 3:
                            lifeInsurance="缴纳不足1年";
                            break;
                        case 4:
                            lifeInsurance="已缴清";
                            break;
                        case 5:
                            lifeInsurance="无保单";
                            break;
                    }
                    customer.setBaodanScop(lifeInsurance);
                });
                Optional.ofNullable(jsonObject.getInteger("creditCard")).ifPresent(v -> {
                    String creditCard="";
                    switch (v){
                        case 1:
                            creditCard="有信用卡";
                            break;
                        case 2:
                            creditCard="无信用卡";
                            break;
                    }
                    customer.setCreditCard(creditCard);
                });
                Optional.ofNullable(jsonObject.getInteger("zhimaScore")).ifPresent(v -> {
                    String zhimaScore="";
                    switch (v){
                        case 1:
                            zhimaScore="700分及以上";
                            break;
                        case 2:
                            zhimaScore="650-700分";
                            break;
                        case 3:
                            zhimaScore="600-650分";
                            break;
                        case 4:
                            zhimaScore="600分以下";
                            break;
                        case 5:
                            zhimaScore="无芝麻分";
                            break;

                    }
                    customer.setSesameScore(zhimaScore);
                });
                Optional.ofNullable(jsonObject.getInteger("overdue")).ifPresent(v -> {
                    String overdue="";
                    switch (v){
                        case 1:
                            overdue="征信良好";
                            break;
                        case 2:
                            overdue="无人行征信";
                            break;
                        case 3:
                            overdue="有逾期，2年内60天以内的逾期";
                            break;
                        case 4:
                            overdue="有逾期，2年内60天以上的逾期";
                            break;
                        case 5:
                            overdue="有逾期，2年内90天以上的逾期";
                            break;
                    }
                    customer.setZx(overdue);
                });
                customer.setLaiyuan("码小米");
                Map map=customerService.savePushCustomer(customer);
                if("200".equals(map.get("code"))){
                    resultMap.put("code",0);
                    resultMap.put("msg","成功");
                }else{
                    resultMap.put("code",-1);
                    resultMap.put("msg","进件失败");
                }

            }catch (Exception e){
                resultMap.put("code",-1);
                resultMap.put("msg","解密失败");
                return resultMap;
            }
        }else{
            resultMap.put("code",-1);
            resultMap.put("msg","channel_code is error or is null");
        }
        return resultMap;
    }


    /**
     * 融金
     * @param param
     * @return
     */
    @Log(title = "客户推送信息-融金撞库接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/rongJinCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertRongJinCheck(@RequestBody JSONObject param) throws Exception {
        Map map=new HashMap();
        if(StringUtils.isNotEmpty(param.getString("mobile"))){
            String phone= param.getString("mobile");
            Customer customer=new Customer();
            customer.setPhoneMD5(phone);
            customer.setCityName(param.getString("city"));
//            customerService.findCustomerByphone(customer)
            if(false){
                map.put("errCode",202);
                map.put("code",202);
                map.put("msg","手机号已存在!");
            }else{
                map.put("errCode",200);
                map.put("code",200);
                map.put("msg","手机号不存在!");
            }
            return map;
        }else{
            map.put("code","401");
            map.put("msg","phone is null");
        }
        return map;
    }

    /**
     * 融金
     * @param param
     * @return
     */
    @Log(title = "客户推送信息-融金推送", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/rongJinInsert", method = RequestMethod.POST)
    @ResponseBody
    public Map rongJinInsert(@RequestBody JSONObject param) throws Exception {
         Map<String,Object> map=new HashMap<>();
         Customer customer=new Customer();
         customer.setLaiyuan("融金");
        Optional.ofNullable(param.getInteger("age")).ifPresent(v -> {
            customer.setAge(v);
        });
        Optional.ofNullable(param.getInteger("sex")).ifPresent(v -> {
            customer.setSex(v==1?"男":"女");
        });
        Optional.ofNullable(param.getString("quota")).ifPresent(v -> {
            customer.setAmount(v);
        });

        Optional.ofNullable(param.getString("username")).ifPresent(v -> {
            customer.setCusName(v);
        });
        Optional.ofNullable(param.getString("mobile")).ifPresent(v -> {
            customer.setPhone(v);
        });
        Optional.ofNullable(param.getString("city")).ifPresent(v -> {
            customer.setCityName(v);
        });
        Optional.ofNullable(param.getString("remark")).ifPresent(v -> {
            customer.setRemark(v);
        });

        Optional.ofNullable(param.getBoolean("isGjj")).ifPresent(v -> {
            customer.setAccumulation(v?"有公积金":"无公积金");
        });
        map=customerService.savePushCustomer(customer);
        if("200".equals(map.get("code"))){
            map.put("code",200);
            map.put("msg","成功");
            map.put("status",200);
        }
        return map;
    }


    @Log(title = "八戒金服-撞库接口", businessType = BusinessType.CHECK)
    @RequestMapping(value = "/baJieCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map baJieCheck(@RequestBody JSONObject param) throws Exception {
        String keyAes="e49AoQW70O5ISfGO";
        Map<String,Object> resultMap=new HashMap<>();
        if(StringUtils.isNotEmpty(param.getString("data"))){
            String data =param.getString("data");
            JSONObject jsonObject=null;
            try{
                jsonObject = JSONObject.parseObject(AesMxmUtils.decrypt(data, keyAes));
            }catch (Exception e){
                resultMap.put("code",-1);
                resultMap.put("msg","解密失败");
                return resultMap;
            }
            if(StringUtils.isNotEmpty(jsonObject.getString("phoneMask"))){
                Customer customer=new Customer();
                customer.setPhone(jsonObject.getString("phoneMask").substring(0,8));
                List<Customer> customers=customerService.findList(customer);
                List<String> list=new ArrayList<>();
                for (Customer cus : customers){
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                resultMap.put("code",200);
                resultMap.put("phoneList",list);
                resultMap.put("msg","成功");
            }else{
                resultMap.put("code",-1);
                resultMap.put("msg","phoneMask is null");
            }
        }else{
            resultMap.put("code",-1);
            resultMap.put("msg","data is error or is null");
        }
        return resultMap;
    }


    @Log(title = "八戒金服-进件", businessType = BusinessType.CHECK)
    @RequestMapping(value = "/baJieApply", method = RequestMethod.POST)
    @ResponseBody
    public Map baJieApply(@RequestBody JSONObject param) throws Exception {
        String laiyuan="八戒金服";
        String keyAes="e49AoQW70O5ISfGO";
        Map<String,Object> resultMap=new HashMap<>();
        if(StringUtils.isNotEmpty(param.getString("data"))){
            String data =param.getString("data");
            JSONObject jsonObject=null;
            try{
                jsonObject = JSONObject.parseObject(AesMxmUtils.decrypt(data, keyAes));
                Customer customer=new Customer();
                customer.setLaiyuan(laiyuan);
                Optional.ofNullable(jsonObject.getString("actualName")).ifPresent(v -> {
                    customer.setCusName(v);
                });
                Optional.ofNullable(jsonObject.getString("phone")).ifPresent(v -> {
                    customer.setPhone(v);
                });
                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(v -> {
                    customer.setAge(v);
                });
                Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                    customer.setCityName(v.replace("市",""));
                });
                Optional.ofNullable(jsonObject.getInteger("sex")).ifPresent(v -> {
                    customer.setSex(v==1?"男":"女");
                });
                Optional.ofNullable(jsonObject.getInteger("loanAmount")).ifPresent(v -> {
                    customer.setAmount(v+"");
                });
                Optional.ofNullable(jsonObject.getString("orderNo")).ifPresent(v -> {
                    customer.setClueId(v);
                });
                Optional.ofNullable(jsonObject.getInteger("professionalIdentity")).ifPresent(v -> {
                    String occupation="";
                    switch (v){
                        case 1:
                            occupation="上班族";
                            break;
                        case 5:
                            occupation="其他职业";
                            break;
                        case 3:
                            occupation="企业主";
                            break;
                        case 4:
                            occupation="个体户";
                            break;
                        case 2:
                            occupation="事业单位/公务员";
                            break;
                    }
                    customer.setWorks(occupation);
                });
                Optional.ofNullable(jsonObject.getInteger("formOfPayroll")).ifPresent(v -> {
                    String salaryMethod="";
                    switch (v){
                        case 1:
                            salaryMethod="银行卡";
                            break;
                        case 3:
                            salaryMethod="自存";
                            break;
                        case 2:
                            salaryMethod="现金发放";
                            break;
                    }
                    customer.setPayoffType(salaryMethod);
                });
                Optional.ofNullable(jsonObject.getInteger("monthlyIncomeType")).ifPresent(v -> {
                    String salaryMoney="";
                    switch (v){
                        case 1:
                            salaryMoney=" 2000以下";
                            break;
                        case 2:
                            salaryMoney="2000-5000";
                            break;
                        case 3:
                            salaryMoney="5000-10000";
                            break;
                        case 4:
                            salaryMoney="10000-15000以上";
                            break;
                        case 5:
                            salaryMoney="15000以上";
                            break;
                    }
                    customer.setIncomeMonth(salaryMoney);
                });
                Optional.ofNullable(jsonObject.getInteger("currentWorkingAge")).ifPresent(v -> {
                    String workAge="";
                    switch (v){
                        case 3:
                            workAge="12个月及以上";
                            break;
                        case 2:
                            workAge="6-12个月";
                            break;
                        case 1:
                            workAge="0-6个月";
                            break;
                    }
                    customer.setWorkingYears(workAge);
                });
                Optional.ofNullable(jsonObject.getInteger("companyMoney")).ifPresent(v -> {
                    String companyMoney="";
                    switch (v){
                        case 1:
                            companyMoney="10-50万";
                            break;
                        case 2:
                            companyMoney="50-100万";
                            break;
                        case 3:
                            companyMoney="100-300万";
                            break;
                        case 4:
                            companyMoney="300万及以上";
                            break;
                        case 5:
                            companyMoney="10万以内";
                            break;
                    }
                    customer.setTurnoverPublic(companyMoney);
                });
                Optional.ofNullable(jsonObject.getInteger("socialSecurity")).ifPresent(v -> {
                    String socialInsurance="";
                    switch (v){
                        case 3:
                            socialInsurance="缴纳6个月以上";
                            break;
                        case 2:
                            socialInsurance="缴纳未满6个月";
                            break;
                        case 1:
                            socialInsurance="无社保";
                            break;
                    }
                    customer.setSocial(socialInsurance);
                });
                Optional.ofNullable(jsonObject.getInteger("providentFund")).ifPresent(v -> {
                    String houseFund="";
                    switch (v){
                        case 3:
                            houseFund="缴纳6个月以上";
                            break;
                        case 2:
                            houseFund="缴纳未满6个月";
                            break;
                        case 1:
                            houseFund="无公积金";
                            break;
                    }
                    customer.setAccumulation(houseFund);
                });
                Optional.ofNullable(jsonObject.getInteger("estate")).ifPresent(v -> {
                    String house="";
                    switch (v){
                        case 2:
                            house="有房";
                            break;
                        case 1:
                            house="无房";
                            break;
                    }
                    customer.setHouseType(house);
                });
                Optional.ofNullable(jsonObject.getInteger("carProduction")).ifPresent(v -> {
                    String car="";
                    switch (v){
                        case 2:
                            car="有车";
                            break;
                        case 1:
                            car="无车产";
                            break;
                    }
                    customer.setCarStatus(car);
                });
                Optional.ofNullable(jsonObject.getInteger("personalInsurance")).ifPresent(v -> {
                    String lifeInsurance="";
                    switch (v){
                        case 4:
                            lifeInsurance="缴纳2年以上";
                            break;
                        case 3:
                            lifeInsurance="缴纳1年以上";
                            break;
                        case 2:
                            lifeInsurance="缴纳不足1年";
                            break;
                        case 1:
                            lifeInsurance="无保单";
                            break;
                    }
                    customer.setBaodanScop(lifeInsurance);
                });
                Optional.ofNullable(jsonObject.getInteger("creditCard")).ifPresent(v -> {
                    String creditCard="";
                    switch (v){
                        case 2:
                            creditCard="有信用卡";
                            break;
                        case 1:
                            creditCard="无信用卡";
                            break;
                    }
                    customer.setCreditCard(creditCard);
                });
                Optional.ofNullable(jsonObject.getInteger("sesame")).ifPresent(v -> {
                    String zhimaScore="";
                    switch (v){
                        case 5:
                            zhimaScore="700分及以上";
                            break;
                        case 4:
                            zhimaScore="650-700分";
                            break;
                        case 3:
                            zhimaScore="600-650分";
                            break;
                        case 2:
                            zhimaScore="600分以下";
                            break;
                        case 1:
                            zhimaScore="无芝麻分";
                            break;

                    }
                    customer.setSesameScore(zhimaScore);
                });
                Optional.ofNullable(jsonObject.getInteger("creditInformation")).ifPresent(v -> {
                    String overdue="";
                    switch (v){
                        case 1:
                            overdue=" 无人行征信记录";
                            break;
                        case 2:
                            overdue="人行征信良好无逾期";
                            break;
                        case 3:
                            overdue="有逾期，2年内60天以内的逾期";
                            break;
                        case 4:
                            overdue="有逾期，2年内60天以上的逾期";
                            break;
                        case 5:
                            overdue="有逾期，2年内90天以上的逾期";
                            break;
                    }
                    customer.setZx(overdue);
                });

                Map map=customerService.savePushCustomer(customer);
                if("200".equals(map.get("code"))){
                    resultMap.put("code",0);
                    resultMap.put("msg","成功");
                }else{
                    resultMap.put("code",-1);
                    resultMap.put("msg","进件失败");
                }

            }catch (Exception e){
                resultMap.put("code",-1);
                resultMap.put("msg","解密失败");
                return resultMap;
            }
        }else{
            resultMap.put("code",-1);
            resultMap.put("msg","channel_code is error or is null");
        }
        return resultMap;
    }

}
